<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue示例一</title>
</head>
<body>
    <div id="app">
        <calc-name></calc-name>
        <calc-name></calc-name>
        <calc-name></calc-name>
        <calc-name></calc-name>
        
    </div>
    <template id="calc">
        <div>
            <h2>当前数：{{data}}</h2>
            <input type="button" value="+" @click = "add">
            <input type="button" value="-" @click = "sub">

        </div>
    </template>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    
    <script>
        Vue.component("calc-name",{
            template:"#calc",
            data:function(){
                return {
                    data:0
                }
            },
            methods:{
                add:function(){
                    this.data ++;
                },
                sub:function(){
                    this.data --;
                }
            }
        })
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!'
            }
        })
    </script>
</body>
</html>